﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using S3Demo.Models;

namespace S3Demo.DAL
{
    public class SchoolInitializer : System.Data.Entity.DropCreateDatabaseIfModelChanges<SchoolContext>
    {
        protected override void Seed(SchoolContext context)
        {
            var students = new List<Student>
            {
                new Student{FirstName="Carson",LastName="Alexander",Birthday=DateTime.Parse("2005-09-01")},
                new Student{FirstName="Meredith",LastName="Alonso",Birthday=DateTime.Parse("2002-09-01")},
                new Student{FirstName="Arturo",LastName="Anand",Birthday=DateTime.Parse("2003-09-01")},
                new Student{FirstName="Gytis",LastName="Barzdukas",Birthday=DateTime.Parse("2002-09-01")},
                new Student{FirstName="Yan",LastName="Li",Birthday=DateTime.Parse("2002-09-01")},
                new Student{FirstName="Peggy",LastName="Justice",Birthday=DateTime.Parse("2001-09-01")},
                new Student{FirstName="Laura",LastName="Norman",Birthday=DateTime.Parse("2003-09-01")},
                new Student{FirstName="Nino",LastName="Olivetto",Birthday=DateTime.Parse("2005-09-01")}
            };

            students.ForEach(s => context.Students.Add(s));
            context.SaveChanges();
        }
    }
}